Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Java 15 Interview Questions and Answers

Question: What is Text Blocks or Multi-line string in Java 15?
Answer:

Until now, when we wanted to define a multi-line string in Java, it usually looked like this:

String sql =
" SELECT id, title, text\n"
+ " FROM Article\n"
+ " WHERE category = \"Java\"\n"
+ "ORDER BY title";

Starting with Java 15, we can notate this string as a "text block":

String sql = """
SELECT id, title, text
FROM Article
WHERE category = "Java"
ORDER BY title""";
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook